package com.bdqn.pojo;

import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import lombok.ToString;

import javax.persistence.*;
import java.io.Serializable;

/**
 * 系统用户
 *
 * @author LILIBO
 * @since 2021-11-22
 */
// @Data // 发生[org.hibernate.HibernateException: collection was evicted]异常，取消@DATA注解，使用手动Getter/Setter
@NoArgsConstructor
@AllArgsConstructor
@ToString
@Entity
@Table(name = "sys_user")
public class UserInfo implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 编号
     */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "usr_id")
    private Long usrId;

    /**
     * 姓名
     */
    @Column(name = "usr_name")
    private String usrName;

    /**
     * 密码
     */
    @Column(name = "usr_password")
    private String usrPassword;

    /**
     * 角色（用户与角色之间：多对一关系）
     */
    @ManyToOne(targetEntity = RoleInfo.class) // 多对一关联关系
    @JoinColumn(name = "usr_role_id") // 外键字段
    private RoleInfo role;

    /**
     * 状态
     */
    @Column(name = "usr_flag")
    private Long usrFlag;

    public UserInfo(String usrName, String usrPassword, RoleInfo role, Long usrFlag) {
        this.usrName = usrName;
        this.usrPassword = usrPassword;
        this.role = role;
        this.usrFlag = usrFlag;
    }

    public Long getUsrId() {
        return usrId;
    }

    public void setUsrId(Long usrId) {
        this.usrId = usrId;
    }

    public String getUsrName() {
        return usrName;
    }

    public void setUsrName(String usrName) {
        this.usrName = usrName;
    }

    public String getUsrPassword() {
        return usrPassword;
    }

    public void setUsrPassword(String usrPassword) {
        this.usrPassword = usrPassword;
    }

    public RoleInfo getRole() {
        return role;
    }

    public void setRole(RoleInfo role) {
        this.role = role;
    }

    public Long getUsrFlag() {
        return usrFlag;
    }

    public void setUsrFlag(Long usrFlag) {
        this.usrFlag = usrFlag;
    }

}
